<!DOCTYPE HTML>
<html>
    <head>
        <title>树</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
        <script src="avalon.$events.js" ></script>
        <script>
            avalon.define("tree", function(vm) {
                vm.tree = [
                    {text: "aaa", subtree: [
                            {text: 1111, subtree: []},
                            {text: 2222, subtree: [
                                    {text: 777, subtree: []}
                                ]},
                            {text: 3333, subtree: [
                                    {text: 8888, subtree: []},
                                    {text: 999, subtree: []}
                                ]}
                        ]},
                    {text: "bbb", subtree: [
                            {text: 4444, subtree: []},
                            {text: 5555, subtree: []},
                            {text: 6666, subtree: []}
                        ]},
                    {text: "ccc", subtree: []},
                    {text: "ddd", subtree: []},
                    {text: "eee", subtree: []},
                    {text: "fff", subtree: []}
                ]

            })
        </script>
    </head>
    <body ms-controller="tree">
        <script type="avalon" id="tmpl">
            <ul ms-each-el="el.subtree">
            <li>{{el.text}}<div ms-include="'tmpl'" ms-visible="el.subtree.length" ></div></li>
            </ul>
        </script>
        <ul ms-each-el="tree">
            <li>{{el.text}}<div ms-include="'tmpl'" ms-visible="el.subtree.length" ></div></li>
        </ul>
    </body>
</html>